/********************************
*
* 名称：Jquery.popBox弹出框插件v1.0
*
* 作者：苏宇豪
*
* 联系方式：qq：644208937
*
*********************************/

$(function(){

	//定义弹出框对象
	function popBox (className,width,type=1){

		this.obj = $('.'+className);

		this.width = width;
		this.height = 200;
		this.background = "blue";
		this.position = "absolute";
		this.top = 0;
		this.left = "50%";
		this.marginLeft = -(width/2);
		this.opacity = 0;
		this.type = type;
		this.speed = 900;

		this.setBox();

	}


	popBox.prototype = {

		//显示对象
		showBox: function(){

			switch(this.type){

				//动画1
				case 1:
					this.obj.css({height:0,opacity:1});
					this.obj.animate({
						top: "150px",
					}).animate({
						height:"200px"
					});
				break;

				//动画2
				case 2:
					this.obj.animate({opacity:1,top:"150px"},this.speed);
				break;

				//动画3(从左到右展开)
				case 3:
					this.obj.css({width:0,top:"150px"});
					this.obj.animate({opacity:1,width:this.width},this.speed);
				break;


			}

		},

		//设置对象属性
		setBox: function(){
			this.obj.css({
				width: this.width,
				height: this.height,
				background: this.background,
				position: this.position,
				top: this.top,
				left: this.left,
				marginLeft: this.marginLeft,
				opacity: this.opacity,
			})
		}


	}


	//设置官方默认样式
	// $(".popBox").append("<div class='tit'></div>");



	// var tmp = new popBox("popBox",500,3);


	// tmp.showBox();


})